/**
 * 
 */
package edu.gtcfla.km.admin.appmodules.vo;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import org.vsg.biz.BusinessEntityFactory;
import org.vsg.biz.account.Module;
import org.vsg.common.web.json.SelectItem;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * @author Bill Vison
 *
 */
public class ModulePermissionVO implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1580059237805257566L;

	private Module module;
	
	private String acl;
	
	private DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	
	private Set<SelectItem> actionEvents = new LinkedHashSet<SelectItem>();	

	private BusinessEntityFactory entityFactory = BusinessEntityFactory.getInstance();		

	public ModulePermissionVO() {
		module = entityFactory.create( Module.class );
	}
	
	public ModulePermissionVO(Module module) {
		this.module = module;
	}

	@JsonProperty("acl") 
	public String getAcl() {
		return acl;
	}



	public void setAcl(String acl) {
		this.acl = acl;
	}


	@JsonProperty("name") 
	public String getName() {
		return module.getName();
	}

	public void setName(String name) {
		module.setName(name);
	}

	public String getVersion() {
		return module.getVersion();
	}

	public void setVersion(String version) {
		module.setVersion(version);
	}

	public void setId(String newId) {
		module.setId(newId);
	}

	public void setDeveloper(String developer) {
		module.setDeveloper(developer);
	}
	
	@JsonProperty("id") 
	public String getId() {
		return module.getId();
	}

	public void setCode(String newCode) {
		module.setCode(newCode);
	}

	public Date getReleaseDate() {
		return module.getReleaseDate();
	}

	public void setReleaseDate(String releaseDate) {
		if (releaseDate != null && !releaseDate.equals("")) {
			try {
				Date date = df.parse(releaseDate);
				module.setReleaseDate(date);
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}	

	@JsonProperty("code") 
	public String getCode() {
		return module.getCode();
	}

	public void setRemark(String newDescription) {
		module.setRemark(newDescription);
	}


	public String getRemark() {
		return module.getRemark();
	}

	public void setDeleted(short newFlagDeleted) {
		module.setDeleted(newFlagDeleted);
	}

	public short getDeleted() {
		return module.getDeleted();
	}

	public Module getModule() {
		return module;
	}

	@Override
	public String toString() {
		return "ModulePermissionVO [getAcl()=" + getAcl() + ", getName()="
				+ getName() + ", getVersion()=" + getVersion() + ", getId()="
				+ getId() + ", getCode()=" + getCode() + "]";
	}

	public Set<SelectItem> getActionEvents() {
		return actionEvents;
	}

	public void setActionEvents(Set<SelectItem> actionEvents) {
		this.actionEvents = actionEvents;
	}

	
	
}
